﻿using Mes.Domain.BoundedContext.Entities.Quality;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.Quality
{
    public class SampleFreqEntityConfig : IEntityTypeConfiguration<SampleFreq>
    {
        public void Configure(EntityTypeBuilder<SampleFreq> builder)
        {
            builder.ToTable("sample_freq");
            builder.HasKey(b => b.Freq_Id);
            builder.Property(b => b.Freq_Name).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Freq_Desc).HasMaxLength(80);
            builder.Property(b => b.Freq_Type).IsRequired().HasDefaultValue(1);
            builder.Property(b => b.Interval);
            builder.Property(b => b.Interval_Unit);
            builder.Property(b => b.Prod_Reset_Option);
            builder.Property(b => b.Offset_Start);
            builder.Property(b => b.Offset_Start_Unit);
            builder.Property(b => b.Offset_End);
            builder.Property(b => b.Offset_End_Unit);
            builder.Property(b => b.Samples_Per_Shift);
            builder.Property(b => b.Multiplier).HasDefaultValue(1).IsRequired();
            builder.Property(b => b.Enabled).IsRequired();
            builder.Property(b => b.Expiry_Time);
            builder.Property(b => b.Expiry_Unit);
            builder.Property(b => b.Warning_Time).HasDefaultValue(5);
            builder.Property(b => b.Warning_Unit).HasDefaultValue(1).IsRequired();
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80);
            builder.Property(b => b.Spare3).HasMaxLength(80);
            builder.Property(b => b.Spare4).HasMaxLength(80);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Freq_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
